﻿using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.AI;

[Serializable]
public class MapLinkNode
{
    public bool directLinked;
    public MapGraphNode node;
    //public MapGraphLink linkPath;
}

[Serializable]
public class MapGraphNode : MonoBehaviour {
    public List<MapLinkNode> MapLinkNodes = new List<MapLinkNode>();
    public GameObject AttachTerrain;
    public string GraphNodeTag;
    

	
	// Update is called once per frame
	void Update () {
        

		
	}

    public bool IsLinkWith(MapGraphNode node)
    {
        int i = node.MapLinkNodes.FindIndex(v => v.node == this);
        if (i == -1) return false;
        var ln = node.MapLinkNodes[i];
        return ln.directLinked;

    }

    public void OnDrawGizmos()
    {
        if (AttachTerrain == null || !AttachTerrain.activeInHierarchy) return;
        foreach(var l in MapLinkNodes)
        {
            if (l.node == null) continue;
            if (IsLinkWith(l.node) ) Gizmos.color = Color.green;
            else Gizmos.color = Color.red;
            Gizmos.DrawLine(transform.position, l.node.transform.position);
        }
        

    }
}
